<!--#include file="lib/utf-8.asp"-->
<!--#include file="lib/connopen.asp"-->
<!--#include file="lib/asp-common-lib.asp"-->
<%
function cf(aaTemp,iFlag)
	cf=false
	if not CheckLogin then
		call ShowError(3)
		exit function
	end if
	if iFlag="" then exit function
	if not IsArray(aaTemp) then exit function
	for i=0 to ubound(aaTemp,2)
		if aaTemp(1,i)<iFlag then exit function
	next
	cf=true
end function


' if not cf(session("aaPostflag"),1) then call ShowError(2)

'获取提交查询的参数
ymid=SafeRequest("ymid",1)
countryid=SafeRequest("countryid",0)
companyid=SafeRequest("companyid",0)
sql="select country,countryid,substr(companyid,1,10) as companyid,company,boxs,cds from (select * from rpt_cc where ymid="&ymid
if countryid<>"" then	sql=sql&" and countryid="&countryid
if companyid<>"" then sql=sql&" and companyid='"&companyid&"'"
sql=sql&"),country,company where countryid=country.id and companyid=company.id "
sql=sql&" order by boxs desc limit 1000"
'组合sql查询字符串
'sql="select * from cdfee where true "
' sql="select "
' sql=sql&" * from rpt_cc where  "
' if ymid<>"" then sql=sql&" ymid="&ymid
' if countryid<>0 then sql=sql&" and countryid="&countryid

' sql=sql&" order by boxs desc limit 1000"
' response.write sql
' response.end
'执行数据查询
set rs = Server.CreateObject("ADODB.Recordset")
rs.cursorlocation=3
rs.open sql,conn,1,1
If rs.eof Then
	response.write("没有检索到数据!")
	response.end
End if

'分页控制
If saferequest("page",0)<>"" Then	page=clng(saferequest("page",0)) Else	page=1
pc=saferequest("pc",1)
If pc="" Then pc=25
rs.pagesize=pc
pagesize=rs.pagesize
pagecount=rs.pagecount
'page=clng(request.QueryString("page"))
if Not IsEmpty(page) then '如果page_num已经初始化...
	if Not IsNumeric(page) then '判断page_num值是否为数字
		page=1
	else
		page = clng(page) '接收page_num并化为数字型赋给page_num变量
	end if
	if page > pagecount then '如果接收的页数大于总页数
		rs.absolutepage = pagecount '设置当前显示页等于最后页
	elseif page <= 0 then '如果page小于等于0
		page=1
		rs.absolutepage = page '设置当前显示页等于第一页
	else
		rs.absolutepage = page '如果大于零,显示当前页等于接收的页数
	end if
	page = rs.absolutepage
end if
%>
<table class="full">
	<thead>
		<tr>
			<th scope="col">序号</th>
			<th scope="col">国家</th>
			<th scope="col">企业</th>
			<th scope="col">箱数</th>
			<th scope="col">票数</th>
		</tr>
	</thead>
	<tbody>
<%
	For i=1 To pagesize
		If rs.eof Then Exit for
%>
		<tr>
			<th class="sub" scope="row"><%=rs.AbsolutePosition%></th>
			<td><a href="rptbrowse.asp?id=<%=ymid%>&countryid=<%=rs("countryid")%>"><%=rs("country")%></a></td>
			<td><a href="rptbrowse.asp?id=<%=ymid%>&companyid=<%=rs("companyid")%>"><%=rs("company")%></a></td>
			<th class="sub" scope="row"><%=rs("boxs")%></th>
			<th class="sub" scope="row"><a href="cdbrowse.asp?id=<%=ymid%>&countryid=<%=rs("countryid")%>&companyid=<%=rs("companyid")%>"><%=rs("cds")%></a></th>
		</tr>
<%
	rs.movenext()
next
%>
	</tbody>
</table>
<div>
	<span id="pagebar">
		共查询到&nbsp;<%=rs.RecordCount%>&nbsp;条记录&nbsp;
		<%	If page>1 Then	%>
			[<a href="#" id="1">首页</a>]
			[<a href="#" id="<%=page-1%>">上一页</a>]
		<%
				End If
				If Not (page>=pagecount Or pagecount=0) Then
		%>
			[<a href="#" id="<%=page+1%>">下一页</a>]
			[<a href="#" id="<%=pagecount%>">尾页</a>]
		<%	End If %>
			第 <%=page%> 页 / 共 <%=pagecount%> 页
			转到<input id="page_val" type="text" size="2" maxlength="<%=Int(Log(pagecount))+1%>" value="<%=page%>" />页
			<input id="page_go" class="bt_button" type="button" value="Go" />
	</span>
</div>
<%
rs.close
Set rs=nothing
%>

<!--#include file="lib/connclose.asp"-->

